Skip to content

community metrics timeseries chart#1770

Merged
simo6529 merged 3 commits intomainfrom
simo6529/community-metrics
Jan 20, 2026
Merged

community metrics timeseries chart#1770
simo6529 merged 3 commits intomainfrom
simo6529/community-metrics

Conversation

@simo6529
Copy link
Copy Markdown
Collaborator

@simo6529 simo6529 commented Jan 20, 2026

Summary by CodeRabbit

  • New Features

    • Metric cards now show inline sparklines for historical trends via a new sparkline component.
    • A new community metrics series API endpoint provides time-series data for enhanced analytics.
    • Dashboard pages now surface series data to populate sparklines across metric cards.
  • Refactor

    • Simplified internal control flow and streamlined data-access patterns.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: Simo <simo@6529.io>
Signed-off-by: Simo <simo@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Adds sparkline support: new MetricSparkline component, a community metrics series React Query hook and API path, and wires sparkline data into MetricCard and CumulativeMetricCard; also updates query keys and OpenAPI schemas.

Changes

Cohort / File(s) Summary
Sparkline component
app/network/metrics/components/MetricSparkline.tsx
New default-export component rendering horizontal sparklines from a numeric array, optional dates for tooltips, and a color; scales bars relative to max and handles empty data.
Metric card components
app/network/metrics/components/MetricCard.tsx, app/network/metrics/components/CumulativeMetricCard.tsx
Added optional props sparklineData, sparklineColor, sparklineDates; conditional rendering of MetricSparkline; adjusted container classNames and Link/group hover behavior.
Page integration
app/network/metrics/page.client.tsx
Added useCommunityMetricsSeries usage and passed series fields (e.g., distinctDroppers, dropsCreated, mainStageSubmissions) plus shared stepsStartTimes to metric cards as sparkline props.
Data hook
hooks/useCommunityMetricsSeries.ts
New hook and exported CommunityMetricsSeriesData shape; fetches /community-metrics/series, computes derived tdhUtilizationPercentage, and configures React Query options (stale/gc/retry/refetch settings).
Query infra
components/react-query-wrapper/ReactQueryWrapper.tsx
Added COMMUNITY_METRICS_SERIES to QueryKey; small control-flow refactors and replaced some optional-chaining with direct nested property access.
API schema
openapi.yaml
Added /community-metrics/series GET path and ApiCommunityMetricsSeries schema; updated ApiMintMetrics with edition_size and unminted fields.

Sequence Diagram(s)

sequenceDiagram
    participant Page as Page.client
    participant Hook as useCommunityMetricsSeries
    participant RQ as React Query
    participant API as Backend API
    participant Card as MetricCard / CumulativeMetricCard
    participant Spark as MetricSparkline

    Page->>Hook: call useCommunityMetricsSeries()
    Hook->>RQ: register query (COMMUNITY_METRICS_SERIES)
    RQ->>API: GET /community-metrics/series
    API-->>RQ: return series arrays
    RQ-->>Hook: provide CommunityMetricsSeriesData
    Hook-->>Page: hook result (series)

    Page->>Card: pass sparklineData, sparklineColor, sparklineDates
    Card->>Spark: render sparkline with data + dates + color
    Spark-->>Spark: invert/scale data, attach tooltips
    Spark-->>Card: render sparkline UI
    Card-->>Page: display metric card with sparkline
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • SZN12 Boosts - TDH 1.4 #1522: Overlapping changes to the metrics client page; may conflict with series data wiring or page structure.
  • Stats to metrics #1744: Modifies the same MetricCard and CumulativeMetricCard components (prop/className changes), likely interacts with sparkline additions.
  • Fix react query lint errors #1687: Modifies ReactQueryWrapper; overlaps with added COMMUNITY_METRICS_SERIES key and related refactors.

Suggested Reviewers

  • ragnep
  • prxt6529

Poem

🐰 Sparklines hop across the screen tonight,
Tiny bars glowing in soft colored light,
Data trails tell tales of days gone by,
Tooltips whisper dates as numbers fly,
A rabbit cheers metrics shining bright!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly relates to the main change: adding sparkline/timeseries chart support to community metrics cards across multiple components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jan 20, 2026

Quality Gate Passed Quality Gate passed

Issues
0 New issues
1 Accepted issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/react-query-wrapper/ReactQueryWrapper.tsx (1)

559-593: Guard nested profileProxy fields to avoid runtime throws.

The ApiProfileMin type defines handle as string | null, and even though created_by and granted_to are non-optional in ApiProfileProxy, the code should defensively guard these nested fields. The current pattern if (profileProxy?.created_by.handle && profileProxy.granted_to.handle) uses optional chaining only on profileProxy but not on the nested fields, risking a runtime throw if the API returns null for created_by or granted_to.

Reintroduce nested optional chaining:

Suggested fix
-    if (profileProxy?.created_by.handle && profileProxy.granted_to.handle) {
+    if (profileProxy?.created_by?.handle && profileProxy?.granted_to?.handle) {

This applies to both locations (lines 559–593 and 643–690).

🧹 Nitpick comments (2)
openapi.yaml (2)

333-360: Clarify timestamp semantics and ordering.

Please document that since/to are UTC Unix millis and that since <= to. Also consider switching the schema type to integer (format int64) for timestamps to avoid ambiguity in codegen.


5851-5926: Document array alignment with steps_start_times.

The schema should state that each metric array is the same length as steps_start_times and aligned by index. Consider adding descriptions (and optional minItems) to make this explicit for client validation/codegen.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
openapi.yaml (1)

7650-7675: Fix required/nullable contract for edition_size and unminted.

edition_size is marked required but nullable, which creates a schema inconsistency. If edition_size can be null (e.g., for unlimited editions), then unminted cannot reliably be calculated as a required non-nullable field. Either:

  • Remove unminted from the required list and mark it nullable, or
  • Remove edition_size from the required list (since nullable fields should not be required)

Choose based on whether unminted can always be computed deterministically regardless of edition_size state.

🧹 Nitpick comments (1)
openapi.yaml (1)

5963-6038: Document series alignment across arrays.
Clarify that each metric array aligns 1:1 with steps_start_times and all arrays are the same length to avoid client-side ambiguity.

♻️ Suggested doc tweak
    ApiCommunityMetricsSeries:
+      description: All metric arrays align 1:1 with steps_start_times and share the same length.
      type: object

@simo6529 simo6529 merged commit 50330aa into main Jan 20, 2026
7 checks passed
@simo6529 simo6529 deleted the simo6529/community-metrics branch January 20, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants